﻿package mortal.game.view.copy.escort
{
    import com.gengine.utils.*;
    import com.mui.containers.globalVariable.*;
    import com.mui.controls.*;
    import extend.language.*;
    import fl.data.*;
    import flash.events.*;
    import mortal.common.global.*;
    import mortal.component.window.*;
    import mortal.game.resource.*;
    import mortal.game.view.common.*;
    import mortal.game.view.copy.escort.renderer.*;
    import mortal.mvc.interfaces.*;

    public class EscortCopySelectTaskWindow extends Window
    {
        private var _explain:GTextFiled;
        private var _list:GTileList;
        private var _arr:Array;
        private static var _instance:EscortCopySelectTaskWindow;

        public function EscortCopySelectTaskWindow(param1:ILayer = null)
        {
            this._arr = [];
            super(param1);
            setSize(750, 445);
            return;
        }// end function

        private function onExplainLink(event:TextEvent) : void
        {
            return;
        }// end function

        public function set todayNum(param1:Object) : void
        {
            this._arr[0] = {type:EscortCopySelectTaskType.ESCORT, todayNum:param1.escortNum};
            this._arr[1] = {type:EscortCopySelectTaskType.HARRY, todayNum:param1.robNum};
            this._list.dataProvider = new DataProvider(this._arr);
            this._list.drawNow();
            this._list.selectedIndex = 0;
            return;
        }// end function

        public function updateState() : void
        {
            var _loc_1:EscortCopySelectTaskRenderer = null;
            var _loc_2:int = 0;
            while (_loc_2 < 2)
            {
                
                _loc_1 = this._list.itemToCellRenderer(this._list.dataProvider.getItemAt(_loc_2)) as EscortCopySelectTaskRenderer;
                _loc_1.updateState();
                _loc_2++;
            }
            return;
        }// end function

        private function onBgLoad() : void
        {
            if (isDisposed)
            {
                return;
            }
            _closeBtn.parent.addChild(_closeBtn);
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            pushUIToDisposeVec(UIFactory.gImageBitmap(ImagesConst.EscortCopySelectTaskWindowBg, 0, 0, this, this.onBgLoad));
            pushUIToDisposeVec(UIFactory.gTextField(Language.getString(70069), 0, 43, 751, 20, this, GlobalStyle.textFormatLv.center(), true));
            this._list = UIFactory.tileList(59, 280, 750, 160, this);
            this._list.setStyle("cellRenderer", EscortCopySelectTaskRenderer);
            this._list.columnWidth = 370;
            this._list.rowHeight = 345;
            this._list.direction = GBoxDirection.HORIZONTAL;
            this._explain = UIFactory.gTextField("", 370, 390, 50, 20, this);
            this._explain.htmlText = HTMLUtil.addLink(Language.getString(70127), GlobalStyle.colorLv);
            this._explain.configEventListener(TextEvent.LINK, this.onExplainLink);
            this.todayNum = {escortNum:2, robNum:4};
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl(param1);
            this._arr.splice(0);
            this._list.dispose(param1);
            this._explain.dispose(param1);
            this._list = null;
            this._explain = null;
            return;
        }// end function

        public static function get instance() : EscortCopySelectTaskWindow
        {
            if (!_instance)
            {
                _instance = new EscortCopySelectTaskWindow;
            }
            return _instance;
        }// end function

        public static function get hasInstance() : Boolean
        {
            return _instance != null;
        }// end function

    }
}
